home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2004 #6 / Amiga Plus CD - 2004 - No. 06.iso / AmigaPlus / Begleitmaterial / 50Tools / Grafik / PerfectPaint / rexx / general / InsertPicture.rx < prev    next >
Text File  |  2003-01-07  |  2KB  |  124 lines

  1. /*     arexx Script 'Insert Picture' */
  2.  
  3.     options results
  4.     parse ARG Port mode b
  5.     
  6.     ADDRESS value Port
  7.  
  8.     pp_GetCurrentBrush; B0=result    
  9.     pp_FindEmptyBrush; Brush=result
  10.     IF Brush=-1 THEN DO; pp_Warn "Can't*find*empty|Brush."; EXIT; END
  11.     pp_SetBrush Brush
  12.  
  13.     file2="ram:multifile"
  14.     IF OPEN('g',file2, 'R') then DO
  15.         file = READLN('g')
  16.         call close('g')
  17.     END
  18.     ELSE
  19.     DO
  20.         EXIT
  21.     END
  22.  
  23.     ADDRESS COMMAND 'delete >nil: ram:multifile'
  24.             file2=""
  25.             do i=1 to LENGTH(file)
  26.                 a=SUBSTR(file,i,1)
  27.                 if a=" " then DO
  28.                     a="*"
  29.                 END
  30.                 file2=file2||a
  31.             END
  32.             file=file2
  33.  
  34.  
  35.     pp_BLoad File
  36.         
  37.     pp_GetWidthB; W=result
  38.     pp_GetHeightB; H=result
  39.     pp_GetWidth; Width=result
  40.     pp_GetHeight; Height=result
  41.  
  42. IF W>0 AND H>0 then DO
  43.  
  44.     pp_GetDepth
  45.     IF result<24 then DO
  46.         pp_RemapBrush
  47.     END
  48.  
  49.     X2=W/2
  50.     Y2=H/2    
  51.     X=Width/2
  52.     Y=Height/2
  53.     X3=X-X2
  54.     Y3=Y-Y2
  55.  
  56.             IF Mode=0 then DO
  57.                 posx=X2;posy=Y2
  58.             END
  59.  
  60.             IF Mode=10 then DO
  61.                 posx=X;posy=Y2
  62.             END
  63.  
  64.             IF Mode=20 then DO
  65.                 posx=X+X3;posy=Y2
  66.             END
  67.  
  68.             IF Mode=3 then DO
  69.                 posx=X2;posy=Y
  70.             END
  71.  
  72.             IF Mode=13 then DO
  73.                 posx=X;posy=Y
  74.             END
  75.  
  76.             IF Mode=23 then DO
  77.                 posx=X+X3;posy=Y
  78.             END
  79.  
  80.             IF Mode=6 then DO
  81.                 posx=X2;posy=Y+Y3
  82.             END
  83.  
  84.             IF Mode=16 then DO
  85.                 posx=X;posy=Y+Y3
  86.             END
  87.  
  88.             IF Mode=26 then DO
  89.                 posx=X+X3;posy=Y+Y3
  90.             END
  91.  
  92.     Ux=posx-W/2-1
  93.     Uy=posy-H/2-1
  94.  
  95.     Ux1=Ux+W+2
  96.     Uy1=Uy+H+2
  97.  
  98.     if Ux<0 then Ux=0
  99.     if Uy<0 then Uy=0
  100.     if Ux1>Width-1 then Ux1=Width-1
  101.     if Uy1>Height-1 then Uy1=Height-1
  102.  
  103.     pp_UpdateUndoBox Ux Uy Ux1 Uy1
  104.  
  105.     pp_EffectOff
  106.     pp_Plot posx posy
  107.  
  108. END    
  109.  
  110.     pp_FreeBrush
  111.     pp_SetBrush B0
  112.  
  113.     EXIT
  114.  
  115.  
  116.  
  117.  
  118.  
  119.     
  120.  
  121.  
  122.     
  123.  
  124.